/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Random;
import java.util.stream.DoubleStream;

/**
 * <p>Project: javase - DoubleArrayDemo
 * <p>Powered by webrx On 2021-12-21 17:20:20
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class DoubleArrayDemo {
    public static void main(String[] args) {
        //double[] ds = DoubleStream.generate(() -> Math.random()).limit(5).toArray();
        double[] ds = DoubleStream.generate(() -> {
                    Random rand = new Random();
                    int s1 = rand.nextInt(90) + 10;
                    double s2 = rand.nextDouble();
                    return Double.parseDouble(String.format("%.2f", s1 + s2));
                })
                .limit(5)
                //.map(a -> .12)
                .map(a -> Double.parseDouble(String.format("%.2f", a)))
                .toArray();
        System.out.println(Arrays.toString(ds));
    }
}
